package wetogether.travelinfo.service;

import java.sql.SQLException;
import java.util.List;

import wetogether.travelinfo.dao.DeleteTravelInfoDAO;
import wetogether.travelinfo.dao.OutputTravelInfoDAO;
import wetogether.travelinfo.vo.TravelCommentVO;
import wetogether.travelinfo.vo.TravelFrVO;
import wetogether.travelinfo.vo.TravelImageVO;
import wetogether.travelinfo.vo.TravelInfoVO;
import wetogether.travelinfo.vo.TravelVacancyVO;

public class DeleteTravelInfoServiceImpl implements DeleteTravelInfoService{
	private DeleteTravelInfoDAO deleteTravelInfoDAO;
	private OutputTravelInfoDAO outputTravelInfoDAO;
	public void setDeleteTravelInfoDAO(DeleteTravelInfoDAO deleteTravelInfoDAO){
		this.deleteTravelInfoDAO=deleteTravelInfoDAO;
		System.out.println("DeleteTravelInfoDAO injection....");
	}
	public void setOutputTravelInfoDAO(OutputTravelInfoDAO outputTravelInfoDAO){
		this.outputTravelInfoDAO=outputTravelInfoDAO;
		System.out.println("OutputTravelInfoDAO injection....");
	}
	/**
	 * 1. 여행지 정보 모두 삭제
	 */
	@Override
	public void deleteTravelInfo(String place) throws SQLException {
		List<String> slist=outputTravelInfoDAO.getPlaceImageList(place);
		if(slist.size()!=0){
			deleteTravelInfoDAO.deleteTotalPlaceImage(place);
			System.out.println(place+"의 이미지 삭제 완료!");
		}
		List<TravelVacancyVO> vlist=outputTravelInfoDAO.getPlaceVacancyList(place);
		if(vlist.size()!=0){
			deleteTravelInfoDAO.deleteTotalPlaceVacancy(place);
			System.out.println(place+"의 숙박 삭제 완료!");
		}
		List<TravelFrVO> flist=outputTravelInfoDAO.getPlaceFrList(place);
		if(flist.size()!=0){
			deleteTravelInfoDAO.deleteTotalPlaceFr(place);
			System.out.println(place+"의 맛집 삭제 완료!");
		}
		deleteTravelInfoDAO.deleteTravelInfo(place);
	}
	/**
	 * 2. 이미지 삭제 - 하나씩
	 */
	@Override
	public void deletePlaceImage(TravelImageVO imgVO) throws SQLException {
		deleteTravelInfoDAO.deletePlaceImage(imgVO);
	}
	/**
	 * 3. 숙박 삭제 - 하나씩
	 */
	@Override
	public void deletePlaceVacancy(TravelVacancyVO vacancyVO)
			throws SQLException {
		deleteTravelInfoDAO.deletePlaceVacancy(vacancyVO);	
	}
	/**
	 * 4. 맛집 삭제 - 하나씩
	 */
	@Override
	public void deletePlaceFr(TravelFrVO frVO) throws SQLException {
		deleteTravelInfoDAO.deletePlaceFr(frVO);
	}
	/**
	 * 5. 공지 삭제
	 */
	@Override
	public void deletePlaceNotice(TravelInfoVO tVO) throws SQLException {
		deleteTravelInfoDAO.deletePlaceNotice(tVO);
	}
	/**
	 * 6. 댓글 삭제
	 */
	@Override
	public void deletePlaceComment(TravelCommentVO commentVO)
			throws SQLException {
		deleteTravelInfoDAO.deletePlaceComment(commentVO);
	}
	/**
	 * 7. 댓글 삭제시 여행정보에 입력했던 추천점수 삭제
	 */
	@Override
	public void deleteTravelInfoRecommend(TravelCommentVO commentVO)
			throws SQLException {
		deleteTravelInfoDAO.deleteTravelInfoRecommend(commentVO);
	}
}
